package Week3.J0502;

import java.util.Scanner;

public class DNA序列_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] arr = scanner.next().toCharArray();
        int len = scanner.nextInt();
        int begin = 0; // 标记起始位置
        int left = 0;
        int right = 0;
        int count = 0;
        int maxCount = 0;

        while (right < arr.length) {
            if (arr[right] == 'C' || arr[right] == 'G') count++;
            while (right - left + 1 > len) {
                if (arr[left] == 'C' || arr[left] == 'G') count--;
                left++;
            }
            if (right - left + 1 == len) {
                if (count > maxCount) {
                    begin = left;
                    maxCount = count;
                }
            }
            right++;
        }

        for (int i = begin; i < begin + len; i++) {
            System.out.print(arr[i]);
        }
    }
}
